Auto Accidents(1975-2017)¶
Import cuXfilter¶
[2]:
import cuXfilter
from cuXfilter import charts
from cuXfilter.layouts import *
from cuXfilter.assets.custom_tiles import get_provider, Vendors
cux_df = cuXfilter.DataFrame.from_arrow('../../../data/auto_accident_loc_data.arrow')
cux_df.data['ST_CASE'] = cux_df.data['ST_CASE'].astype('float64')
gtc_demo_red_blue_palette = [ (49,130,189), (107,174,214), (123, 142, 216), (226,103,152), (255,0,104) , (50,50,50) ]
Define Charts¶
[5]:
# add mappings for day of week
label_map = {
1: 'Sunday',
2: 'Monday',
3: 'Tuesday',
4: 'Wednesday',
5: 'Thursday',
6: 'Friday',
7: 'Saturday',
9: 'Unknown'
}
[6]:
chart1 = charts.cudatashader.scatter_geo(x='dropoff_x', y='dropoff_y', aggregate_col='ST_CASE',
tile_provider=get_provider(Vendors.MAPBOX_LIGHT, access_token=MAPBOX_TOKEN),
color_palette=gtc_demo_red_blue_palette,)
chart2 = charts.panel_widgets.multi_select('YEAR')
chart3 = charts.bokeh.bar('DAY_WEEK', x_label_map=label_map)
Create a dashboard object¶
[7]:
d = cux_df.dashboard([chart1, chart3, chart2], layout=cuXfilter.layouts.feature_and_base,theme = cuXfilter.themes.rapids, title='Auto Accident Dataset')
[8]:
#dashboard object
d
[8]:
Starting the dashboard¶
d.show(‘url you want the dashboard to run’) remote dashboard
d.app(‘10.110.47.43:8888’) within the notebook: If you are using jupyter remotely, use this line instead of second, and replace url with current notebook url
[9]:
await d.preview()
Export the queried data into a dataframe¶
[13]:
queried_df = d.export()
no querying done, returning original dataframe